package com.htpay.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.htpay.mapper.MerchantWalletMapper;
import com.htpay.model.entity.MerchantWalletInfo;
import com.htpay.service.IMerchantWalletService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 服务类
 * <p>
 * 商户钱包余额表 - 实现类
 */
@Service
public class MerchantWalletServiceImpl extends ServiceImpl<MerchantWalletMapper, MerchantWalletInfo> implements IMerchantWalletService {
    @Autowired
    MerchantWalletMapper merchantWalletMapper;

    @Override
    public void addMerchantWalletInfo(MerchantWalletInfo merchantWalletInfo) {
        this.save(merchantWalletInfo);
    }

    @Override
    public MerchantWalletInfo getWalletInfoByMerchantId(int merchantId) {
        return merchantWalletMapper.getWalletInfoByMerchantId(merchantId);
    }

    @Override
    public void updateWithdrawPwd(Integer merchantId, String pwd) {
        LambdaQueryWrapper<MerchantWalletInfo> condition = new LambdaQueryWrapper<MerchantWalletInfo>().eq(MerchantWalletInfo::getMerchantId, merchantId);
        merchantWalletMapper.update(new MerchantWalletInfo().setWithdrawPassword(pwd), condition);
    }
}
